#include "stdafx.h"
#include "Random.h"

namespace Core
{
	Random::Random()
	{
		srand((unsigned int) time(0));
	}

	unsigned long Random::Next()
	{
		return rand();
	}

	unsigned long Random::Next(unsigned long p_Max)
	{
		return (unsigned long) (rand()*((double) p_Max/RAND_MAX));
	}

	unsigned long Random::Next(unsigned long p_Min, unsigned long p_Max)
	{
		if(p_Max < p_Min)
		{
			unsigned long t_Long = p_Max;
			p_Max = p_Min;
			p_Min = t_Long;
		}
		return p_Min + Next(p_Max-p_Min);
	}
}
